package com.mallcloud.mall.mall.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.app.mapper.AppProcedureMapper;
import com.mallcloud.mall.common.core.exception.FailException;
import com.mallcloud.mall.common.data.resolver.TenantResolver;
import com.mallcloud.mall.mall.api.entity.XglParkingRecordModel;
import com.mallcloud.mall.mall.api.entity.dto.ProXglParkingRedeemRecordReporting;
import com.mallcloud.mall.mall.mapper.XglParkRecordMapper;
import com.mallcloud.mall.mall.service.XglParkingRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 *  星光里停车兑换记录
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class XglParkRecordServiceImpl extends ServiceImpl<XglParkRecordMapper, XglParkingRecordModel> implements XglParkingRecordService {

	private final AppProcedureMapper procedureMapper;

	@Override
	public void ProXglParkingRedeemRecordReporting(ProXglParkingRedeemRecordReporting dto) {
		if(StrUtil.isBlank(dto.getStoreNo())){
			dto.setStoreNo(TenantResolver.getById().getCode());
		}
		procedureMapper.ProXglParkingRedeemRecordReporting(dto);
		if(!dto.isSuccess()) {
			log.error("停车券兑换记录生成失败");
			throw new FailException(dto.getMessage());
		}
	}
}
